import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    extensions: ['.js', '.vue', '.json'],
  },
  build: {
    lib: {
      entry: path.resolve(__dirname, 'package/index.js'),
      name: 'EasyUI',
      fileName: (format) => {
        if (format === 'es') return 'easy-ui.es.js'
        if (format === 'umd') return 'easy-ui.umd.js'
        return `easy-ui.${format}.js`
      },
      formats: ['es', 'umd']
    },
  },
  rollupOptions: {
    external: ['vue'],
    // 输入配置
    input: {
      main: path.resolve(__dirname, 'package/index.js'),
    },
    sourcemap: true,
  }
})
